import java.util.Scanner;

public class Main {

/*//第一题 排列子序列
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n =  scanner.nextInt();
        int[] arry = new int[n+1];

        for (int i = 0; i < n; i++) {
            arry[i] = scanner.nextInt();
        }
        int i = 0;
        int count = 0;
        while (i<n) {
            if(arry[i] >arry[i+1]) {
                while (i < n &&arry[i] >arry[i+1]){
                    i++;
                }
                i++;
                count++;
            }else  if(arry[i] == arry[i+1]) {
                i++;
            }else {
                while (i<n && arry[i] <arry[i+1]) {
                    i++;
                }
                i++;
                count++;
            }

        }
        System.out.println(count);
    }*/
    /*//排序子序列  下面错误方法
        public static void main(String[] args) {
            Scanner scanner = new Scanner(System.in);
            int n = scanner.nextInt();
            long[] arry = new long[n];

            for (int i = 0; i < n; i++) {
                arry[i] =scanner.nextLong();
            }

            int num = 1;
            if ((arry[0] >arry[1]&&arry[0] <arry[2])||(arry[0] <arry[1]&&arry[0] >arry[2])||(arry[n-1] >arry[n-2]&&arry[-1] <arry[n-3])||(arry[n-1] <arry[n-2]&&arry[n-1] >arry[n-3])){
                num++;
            }

            for (int i = 1; i < n-1; i++) {
             if (((arry[i] > arry[i + 1]) && (arry[i] > arry[i - 1])) || ((arry[i]) < arry[i - 1]) && (arry[i] < arry[i + 1])) {
                    num++;
                }

            }
            System.out.println(num);

        }
*/

    public static void resver(char[] cha, int star, int length) {//前后倒序

        while (star < length) {
            char s = cha[star];
            cha[star] = cha[length];
            cha[length] = s;
            star++;
            length--;
        }

    }


    public static void main1(String[] args) {

        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        char[] ch = str.toCharArray();
        int len = ch.length;
        resver(ch, 0, len - 1);

        int i = 0;
        int j= 0;
        while (j<len){
            j = i;
            while (j<len&&ch[j] != ' '){
                j++;
            }
            if(j <len){
                resver(ch,i,j-1);
                i = j+1;
            }else {
                resver(ch,i,j-1);
                i = j;
            }

        }



        String s = new String(ch);
            System.out.println(s);

        }
    }
   /* //第二题 将字符串以空格分割后 倒序输出
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String a = scanner.nextLine();
        char[] c = a.toCharArray();
        int sum = 0;
        for (int i = 0; i < a.length(); i++) {
            if(c[i]==' ') {
                sum++;
            }
        }
        String[] s = a.split(" ");
        for (int i = sum; i >= 0; i--) {
            System.out.print(s[i] + " ");
        }
    }*/

